package com.authine.cloudpivot.web.api.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.engine.api.facade.IMMessageFacade;
import com.authine.cloudpivot.engine.api.model.im.MessageModel;
import com.authine.cloudpivot.engine.api.model.runtime.AttachmentModel;
import com.authine.cloudpivot.engine.enums.type.IMMessageChannelType;
import com.authine.cloudpivot.engine.enums.type.IMMessageType;
import com.authine.cloudpivot.web.api.dao.*;
import com.authine.cloudpivot.web.api.dubbo.DubboConfigService;
import com.authine.cloudpivot.web.api.service.FescoadTwoDevelopmentService;
import com.authine.cloudpivot.web.api.vo.*;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Service;

import java.util.*;


@Slf4j
@Service
public class FescoadTwoDevelopmentImpl implements FescoadTwoDevelopmentService {

    @Autowired
    private XMKXXMapper xmkxxMapper;

    @Autowired
    private ProjectDetailMapper projectDetailMapper;

    @Autowired
    private ExecutiveDetailsMapper executiveDetailsMapper;

    @Autowired
    private XMQDMapper xmqdMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private XZDJXQMapper xzdjxqMapper;

    @Autowired
    private TestMapper testMapper;
    @Autowired
    private DubboConfigService dubboConfigService;

    @Autowired
    private ProjectTeamMapper projectTeamMapper;

    @Autowired
    private WorkDetailMapper workDetailMapper;

    @Autowired
    private WHMDXXMapper whmdxxMapper;

    @Autowired
    private EmpleeManagerMapper empleeManagerMapper;

    @Autowired
    private GSLXMapper gslxMapper;

    @Autowired
    private XMZBDJMapper xmzbdjMapper;

    @Autowired
    private StoreSupervisorMapper storeSupervisorMapper;

    @Autowired
    private YGGLTMapper yggltMapper ;

    @Autowired
    private XXPZMapper xxpzMapper;

    @Autowired
    private PostionInformationMapper postionInformationMapper;

    @Autowired
    private RedisTemplate<String, AttachmentModel> redisTemplate;

    @Override
    public void updateXMKXXStatus(String code) {
        xmkxxMapper.updateXMKXXStatus(code);
    }

    @Override
    public void insertXMJD(String objectId) {
        //查询店检需求
        XZDJXQ xmxq = xzdjxqMapper.getXMXQ(objectId);




        //查询字表中信息
        List<DJJD> list = new ArrayList<>();

        List<Map> ziBiao = xzdjxqMapper.getZiBiao(objectId);

        for (int i = 0; i <ziBiao.size() ; i++) {
            //插入店检进度
            DJJD d = new DJJD();
            d.setCreateddeptid(xmxq.getCreateddeptid());
            d.setCreatedtime(xmxq.getCreatedtime());
            d.setModifiedtime(xmxq.getModifiedtime());
            d.setModifier(xmxq.getModifier());
            d.setOwner(xmxq.getOwner());
            d.setOwnerdeptid(xmxq.getOwnerdeptid());
            d.setCreater(xmxq.getCreater());
            d.setSequencestatus(xmxq.getSequencestatus());
            d.setOwnerdeptquerycode(xmxq.getOwnerdeptquerycode());
            d.setSubjectName(xmxq.getSubjectName());  //项目名称
            d.setProjectNo(xmxq.getProjectNo());
            d.setStartTime(xmxq.getStartTime());  //开始时间
            d.setEndTime(xmxq.getEndTime());
            d.setShopInspectNo(xmxq.getStoreRotation());   //店检轮次
            d.setSubjectNames(xmxq.getSubjectNames());
            d.setId(generationId("iden7_DJJD"));
            d.setStoreNum(getString(ziBiao.get(i).get("storeNum")));//门店编号
            d.setStoreName(getString(ziBiao.get(i).get("storeName"))); //店铺名
            d.setProvince(getString(ziBiao.get(i).get("province"))); //shen
            d.setCityName(getString(ziBiao.get(i).get("cityName")));//chengshi
            d.setCityLevel(getString(ziBiao.get(i).get("cityLevel"))); //jibie
            d.setSettlement(getString(ziBiao.get(i).get("isOver"))); //shifoujiesuan
            d.setShopNames(getString(ziBiao.get(i).get("storeNames")));
            list.add(d);
        }
        xzdjxqMapper.inserDJJD(list);
    }

    @Override
    public void workTime(String id) {
        //查询项目类型 名称
        List<WorkDetail> stringStringMap = workDetailMapper.selectWorkType(id);
        for (int i = 0; i < stringStringMap.size(); i++) {
            if(!"项目".equals(stringStringMap.get(i).getWorktype())){
                continue;
            }
            Integer count = workDetailMapper.selectWorkTypeCount(stringStringMap.get(i).getWorktype(),id);
            workDetailMapper.updateCount(count,id);
        }


    }


    @Override
    public void mdDetail() {
        List<WHMDXX> list = whmdxxMapper.mdDetail();

        for (int i = 0; i < list.size(); i++) {
            if(list.get(i)!=null){
                Integer count = whmdxxMapper.selectCountByName(list.get(i).getSubjectName());
                whmdxxMapper.updateCount(count,list.get(i).getSubjectName());
            }
        }

    }

    @Override
    public void mdCount() {
        whmdxxMapper.updateTotalCount(1);

    }

    @Override
    public String sendInformation(String userId,String name,String id) {
        sendMessage(userId,"form/detail?schemaCode=postionInformation","请补充上岗信息",name+"  上岗信息");
       empleeManagerMapper.udpateStatus(id);

        return "success";
    }

    @Override
    public void sendInformationPOI() {

        List<WHMDXX> list  =  whmdxxMapper.selectChange();
        for (int i = 0; i <list.size(); i++) {
            if ("是".equals(list.get(i).getIsNotDuDao())) {
                if("否".equals(list.get(i).getIsHavePersons())){
                    //给执行经理 推送消息
                    if(list.get(i).getEManager() != null){
                        List<Map> list1 = (List<Map>) JSON.parse(list.get(i).getEManager());
                        for (int j = 0; j < list1.size(); j++) {
                            Map m = list1.get(0);
                            String id = (String) m.get("id");
                            User user =  userMapper.getUserId(id);
                            log.info("推送门店督导列表信息----");
                            sendMessage(user.getUserId(),"form/detail?schemaCode=storeSupervisor","门店督导列表",user.getName()+"  门店督导列表");
                        }
                    }
                }
            }
            whmdxxMapper.updateIsChage(list.get(i).getId());
        }


        //查询status =“” 的员工
       List<EmpleeManager> list3 =  empleeManagerMapper.sendInformationPOI();

        for (int i = 0; i < list3.size(); i++) {
            //发送消息
            List<Map> list1 = (List<Map>) JSON.parse(list3.get(i).getEmployee());
            Map m = list1.get(0);
            String id = (String) m.get("id");
            User user =  userMapper.getUserId(id);
         sendMessage(user.getUserId(),"form/detail?schemaCode=postionInformation","请补充上岗信息",user.getName()+"  上岗信息");
            //更新 status
            empleeManagerMapper.udpateStatus(list.get(i).getId());
        }

    }

    @Override
    public void bachInsertDJJD() {
        //查询所有
        List<XZDJXQ> all = xzdjxqMapper.getAll();
        for (int i = 0; i <all.size() ; i++) {
            insertXMJD(all.get(i).getId());
            xzdjxqMapper.updateXMJD(all.get(i).getId());
        }

    }

    @Override
    public void subjectNumberUpdate(String id) {
        ProjectTeam projectTeam = projectTeamMapper.subjectNumberUpdate(id);
        //更新 工时类型中的 成员
        if(projectTeam.getMember()!=null){
          gslxMapper.updateRoles(projectTeam.getPeojectno(),projectTeam.getMember());
        }

    }

    @Override
    public void updateGslxRole() {
        String status0 = "否";
        String status1= "更换成员";
        List<ProjectTeam> projectTeam =projectTeamMapper.selectAllByStatus(status0);

        List<ProjectTeam> projectTeam11 =projectTeamMapper.selectAllByStatus(status1);


       for (int i = 0; i < projectTeam.size(); i++) {

            GSLX gslx =gslxMapper.getMeber(projectTeam.get(i).getPeojectno());
            if(gslx==null){
                continue;
            }
            String roles = gslx.getRoles();
            String roles1 = projectTeam.get(i).getMember();
            if(roles1!=null){
                List<Map> list1 = (List<Map>) JSON.parse( roles1);
                if(roles !=null){
                    List<Map> list = (List<Map>) JSON.parse( roles);
                    for (int j = 0; j < list.size(); j++) {
                        Map m = list.get(j);
                        String id = (String) m.get("id");
                        Map map = new HashMap();
                        map.put("id",id);
                        map.put("type","3");
                        //工时类型 数据添加到 组建团队 roles  list中，json解析 list1中
                        list1.add(map);
                    }
                }
                String s = JSON.toJSONString(list1);
                gslxMapper.updateRoles(projectTeam.get(i).getPeojectno(),s);
                projectTeamMapper.updateStatus(projectTeam.get(i).getId());
            }

        }

            for (int i = 0; i <projectTeam11.size() ; i++) {
                //查询 项目可行性中的项目经理
                String role0 = xmkxxMapper.getSujectPerson(projectTeam.get(i).getSubjectname());
            }

    }

    @Override
    public void selectUser() {

       List<User> list =  userMapper.selectUser();
       List<Map> listMap = new ArrayList<>();

        for (int i = 0; i <list.size() ; i++) {
            Map map = new HashMap();
            map.put("id",list.get(i).getId());
            map.put("type","3");
            listMap.add(map);
        }
        String s = JSON.toJSONString(listMap);
        //更新工时 人员多选
        gslxMapper.updatePartRoles(s);
    }

    @Override
    public void updateSujectManager(String objectId, String role) {
        //更新项目经理
        //项目可行性项目更新 项目经理
        XMQD xmqd = xmqdMapper.selectSujectName(objectId);
        xmkxxMapper.updateSubjectManager(xmqd.getSubjectname(),role);

        //项目立项，

    }

    @Override
    public String selectProject(String subjectName, String projectNo) {
        return xmqdMapper.selectProject(subjectName,projectNo);
    }


    @Override
    public String getId() {
        String uuid = UUID.randomUUID().toString().replace("-","");
        String id = testMapper.selectTableById(uuid,"iden7_WHMDXX");
        if(id==null){
            return uuid;
        }else{
            getId();
        }
        return null;
    }

    @Override
    public User getOwner(String owner) {
        return userMapper.getUser(owner);
    }

    @Override
    public void sendMessageToDuDao(String userId,String storeName) {
        sendMessage(userId,"form/detail?schemaCode=WHMDXX&sheetCode=WHMDXX",storeName+"门店 已分配给您","门店信息补充");
    }

    @Override
    public void insertAll(List<StoreSupervisor> storeSupervisor) {
         storeSupervisorMapper.insertAll(storeSupervisor);
    }

    @Override
    public String getStoreName(String storeShortName , String sequenceNo) {
        return whmdxxMapper.getstoreName(storeShortName,sequenceNo);
    }

    @Override
    public String getGrade(String subjectName, String score) {
        return xmzbdjMapper.getGrade(subjectName,score);
    }

    @Override
    public List<PostionInformation> getStoreName1(String id,String objectId) {

      //  List<YGGLT> ygglts = yggltMapper.getStoreName(id,objectId);
        List<PostionInformation> list = postionInformationMapper.getStoreName(id,objectId);
        return  list;
    }

    @Override
    public List<String> getArea(String id) {
        List<String>   areaList= new ArrayList<>();;
        areaList= whmdxxMapper.getArea(id);
        areaList.add("全部");
        return areaList;
    }

    @Override
    public Map getPerson(String id) {
       Map map = storeSupervisorMapper.getPerson(id);
       List<String> lsit1 = new ArrayList<>();
       lsit1.add(map.get("member").toString());
        List<String> lsit2 = new ArrayList<>();
        lsit2.add(map.get("emanager").toString());
       map.put("member",formatPerson(lsit1));
       map.put("emanager",formatPerson(lsit2));
        return map;
    }

    @Override
    public void sendMessage(String id,String messageLink,String messageName) {
        //查询userid
        String[] split = id.split(";");
        for (int i = 0; i < split.length; i++) {
            log.info("userId----",split[i]);
            log.info("messageLink----",messageLink);
            sendMessage(split[i],messageLink,messageName,messageName);
        }
    }

    @Override
    public void sendMessageTime() {
       List<XXPZ> list= xxpzMapper.getRole("周期性");
        for (int i = 0; i < list.size(); i++) {
            Date date = new Date();
            Date starttime = list.get(i).getStarttime();
            Date endtime = list.get(i).getEndtime();
            boolean flag = starttime !=null&&endtime !=null;
            //当前时间 在开始时间和结束时间 之间
            if(flag&&starttime.before(date)&&endtime.after(date)){
                XXPZ xxpz = list.get(i);
                Calendar cal = Calendar.getInstance();
                String times = list.get(i).getTimes();
                if("每月一次".equals(times)){
                    //每月一次
                    System.out.println(cal.get(Calendar.DAY_OF_MONTH));
                    if(xxpz.getNodes().intValue()==cal.get(Calendar.DAY_OF_MONTH)){
                        sendmessage(xxpz);
                    }
                }else if("每周一次".equals(times)){
                    // 每周一次
                    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
                    if(xxpz.getNodes().intValue()==w){
                        sendmessage(xxpz);
                    }
                }else if("每两周一次".equals(times)){
                    //每两周一次
                    int w1 = cal.get(Calendar.DAY_OF_WEEK) - 1;
                    if(xxpz.getNodes().intValue()==w1){
                        if(xxpz.getSign()%2==0){
                            sendmessage(xxpz);
                        }
                        xxpzMapper.updateSign(xxpz.getSign()+1,xxpz.getId());
                    }
                }
            }
        }
    }
    public void sendmessage( XXPZ xxpz){
        List<Map> list1 = (List<Map>) JSON.parse(xxpz.getRoles());
        for (int j = 0; j < list1.size(); j++) {
            Map m = list1.get(j);
            log.info("钉钉设置通知消息---");
         sendMessage(userMapper.getUserId((String) m.get("id")).getUserId(),xxpz.getMessagelink(),xxpz.getMessagename(),xxpz.getMessagename());
        }
    }

    @Override
    public String getRole(String subjectId) {
        List<ProjectTeam> roles = projectTeamMapper.getRole(subjectId);
        ProjectTeam role = roles.get(0);
        if(role!=null){
            if(role.getRole()==null){
                return role.getRoles();
            }
            return role.getRole();
        }

        return null;
    }

    @Override
    public void updateCustomInformation(String subjectName, String customName, String customCode) {
        xmqdMapper.updateCustomInformation(subjectName,customName,customCode);
    }

    @Override
    public void seleckkkk() {
        List<XMQD> all = xmqdMapper.getAll1();
        for (int i = 0; i <all.size() ; i++) {
             List<ProjectTeam> list = projectTeamMapper.getProject( all.get(i).getId(),"项目经理");
             if(list.size()>0){
                 continue;
             }
             else {
                 List<Map> listMap = new ArrayList<>();

                 String emanager = all.get(i).getSubjectperson();
                 String id = UUID.randomUUID().toString().replace("-", "");
                 System.out.println(id);
                 if (emanager != null && !("".equals(emanager))) {
                     List<Map> list1 = (List<Map>) JSON.parse(emanager);
                     for (int j = 0; j < list1.size(); j++) {
                         Map map = new HashMap();
                         map.put("id", list1.get(j).get("id"));
                         map.put("type", "3");
                         listMap.add(map);
                         String s = JSON.toJSONString(listMap);
                         projectTeamMapper.insertProject(list1.get(j).get("id").toString(), all.get(i).getOwner(), all.get(i).getCreateddeptid(), all.get(i).getOwnerdeptid(), all.get(i).getProjectno(), "组建团队-" + all.get(i).getName(), id, all.get(i).getId(), s, "项目经理", all.get(i).getSubjectstarttime(), all.get(i).getSubjectendtime(),all.get(i).getCreatedtime());
                     }
                 }
//                 else {
//                     projectTeamMapper.insertProject(all.get(i).getCreater(), all.get(i).getOwner(), all.get(i).getCreateddeptid(), all.get(i).getOwnerdeptid(), all.get(i).getProjectno(), "组建团队-" + all.get(i).getName(), id, all.get(i).getId(), null, "项目经理", all.get(i).getSubjectstarttime(), all.get(i).getSubjectendtime());
//                 }
             }
        }
    }

    @Override
    public void selectjjj() {
        List<XMQD> all = xmqdMapper.getAll1();
            String role = "项目经理";
        for (int i = 0; i <all.size() ; i++) {

            List<ExecutiveDetails> list = executiveDetailsMapper.getProject( all.get(i).getId(),role);
            if(list.size()>0){
                continue;
            }
            else{
                List<Map> listMap = new ArrayList<>();
                String emanager = all.get(i).getEmanager();
                String id =UUID.randomUUID().toString().replace("-", "");
                System.out.println(id);
                if(emanager!=null&&!("".equals(emanager))){
                    List<Map> list1 = (List<Map>) JSON.parse(emanager);
                    for (int j = 0; j <list1.size() ; j++) {
                        Map map = new HashMap();
                        map.put("id", list1.get(j).get("id"));
                        map.put("type","3");
                        listMap.add(map);
                    }
                    String s = JSON.toJSONString(listMap);

                    executiveDetailsMapper.insertProject("","",all.get(i).getCreater(),all.get(i).getOwner(),all.get(i).getCreateddeptid(),all.get(i).getOwnerdeptid(),all.get(i).getProjectno(),id,all.get(i).getId(),s,role,all.get(i).getSubjectstarttime(),all.get(i).getSubjectendtime(),all.get(i).getCreatedtime());
                }else{
                    executiveDetailsMapper.insertProject("","",all.get(i).getCreater(),all.get(i).getOwner(),all.get(i).getCreateddeptid(),all.get(i).getOwnerdeptid(),all.get(i).getProjectno(),id,all.get(i).getId(),null,role,all.get(i).getSubjectstarttime(),all.get(i).getSubjectendtime(),all.get(i).getCreatedtime());
                }


            }
        }
    }

    @Override
    public void selectHHHH() {
        List<WHMDXX> whmdxxes = whmdxxMapper.selectall();
        for (int i = 0; i < whmdxxes.size(); i++) {
         List<ProjectDetail> list =    projectDetailMapper.selectk(whmdxxes.get(i).getId(),whmdxxes.get(i).getSubjectName());
            if(list.size()>0){
                continue;
            }else{
                String id =UUID.randomUUID().toString().replace("-", "");
                projectDetailMapper.insertK(whmdxxes.get(i).getCreater(),whmdxxes.get(i).getOwner(),whmdxxes.get(i).getCreateddeptid(),whmdxxes.get(i).getOwnerdeptid(),id,whmdxxes.get(i).getId(),whmdxxes.get(i).getSubjectName(),whmdxxes.get(i).getProvince());
            }
        }
    }

    @Override
    public void selectsss() {
        String kf= "客服";
        String xmzl="项目助理";
        String  memberTotal = "";
        List<ProjectTeam> listProjectTeam  = projectTeamMapper.getAll(kf,xmzl);
            //一个项目可能很多客服和助理
        for (int i = 0; i < listProjectTeam.size(); i++) {
            ProjectTeam projectTeam = listProjectTeam.get(i);
            List<Map> listss = (List<Map>) JSON.parse(projectTeam.getMember());
            String customerS ="";
            String projectAss ="";
            XMQD  xmqd =   xmqdMapper.seletById(projectTeam.getSubjectname());
           if(listss !=null){
               if (kf.equals(projectTeam.getRole())) {
                       List<Map> listMap = new ArrayList<>();
                       if(xmqd.getCustomerS()!=null){
                           List<Map> lists = (List<Map>) JSON.parse(xmqd.getCustomerS());
                           if(lists != null){
                               for (int j = 0; j <lists.size() ; j++) {
                                   Map map = new HashMap();
                                   map.put("id", lists.get(j).get("id"));
                                   map.put("type",3);
                                   listMap.add(map);
                               }
                           }
                           Map ma = new HashMap();
                           ma.put("id",listss.get(0).get("id"));
                           ma.put("type",3);
                           listMap.add(ma);
                           customerS = JSON.toJSONString(listMap);
                       }
                   }
               //查询  项目立项


               if (xmzl.equals(projectTeam.getRole())) {
                   //查询  项目立项
                   List<Map> listMap = new ArrayList<>();
                   if(xmqd.getCustomnames()!=null) {
                       List<Map> lists = (List<Map>) JSON.parse(xmqd.getProjectAss());
                       if (lists != null) {
                           for (int j = 0; j < lists.size(); j++) {
                               Map map = new HashMap();
                               map.put("id", lists.get(j).get("id"));
                               map.put("type", 3);
                               listMap.add(map);
                           }
                       }
                       Map ma = new HashMap();
                       ma.put("id", listss.get(0).get("id"));
                       ma.put("type",3);
                       listMap.add(ma);
                       projectAss = JSON.toJSONString(listMap);
                   }
               }

               String memberTotal1 =   xmqd.getMemberTotal();
               List<Map> listMap = new ArrayList<>();
               if(memberTotal1 !=null){
                   //里面是有数据的
                   List<Map> list1 = (List<Map>) JSON.parse(memberTotal1);
                   for (int j = 0; j <list1.size() ; j++) {
                       Map map = new HashMap();
                       map.put("id", list1.get(j).get("id"));
                       map.put("type",3);
                       listMap.add(map);
                   }
               }
               Map ma = new HashMap();
               ma.put("id",listss.get(0).get("id"));
               ma.put("type",3);
               listMap.add(ma);
               memberTotal = JSON.toJSONString(listMap);
               xmqdMapper.updateUser(customerS,projectAss,memberTotal,projectTeam.getSubjectname());
           }

        }
    }

    @Override
    public void sel() {
//        String zxjl = "执行经理";
//        List<ProjectTeam> listProjectTeam  = projectTeamMapper.getAll(zxjl,"11111");
//
//        for (int i = 0; i < listProjectTeam.size() ; i++) {
//            ProjectTeam projectTeam = listProjectTeam.get(i);
//
//            if ( projectTeam.getMember()!=null) {
//                List<Map> list1 = (List<Map>) JSON.parse(projectTeam.getMember());
//                if(list1.size()>1){
//                    //重新生成 组建团队
//                    for (int j = 0; j < list1.size() ; j++) {
//                        if(j==0){
//                            continue;
//                        }
//                        String id =UUID.randomUUID().toString().replace("-", "");
//                        System.out.println(id);
//                        // executiveDetailsMapper.insertProject(all.get(i).getCreater(),all.get(i).getOwner(),all.get(i).getCreateddeptid(),all.get(i).getOwnerdeptid(),all.get(i).getProjectno(),id,all.get(i).getId(),s,role,all.get(i).getSubjectstarttime(),all.get(i).getSubjectendtime());
//                        ProjectTeam p = new ProjectTeam();
//                        p.setId(id);
//                        p.setCreater(list1.get(j).get("id").toString());
//                        p.setOwner(list1.get(j).get("id").toString());
//
//                        p.setPeojectno(projectTeam.getPeojectno());
//                        p.setRole("执行经理");
//                        List list = new ArrayList();
//                        Map listMap = new HashMap();
//                        listMap.put("id",list1.get(0).get("id"));
//                        listMap.put("type",3);
//                        list.add(listMap);
//                        p.setMember(JSON.toJSONString(list));
//                        p.setStarttime(projectTeam.getStarttime());
//                        p.setEndtime(projectTeam.getEndtime());
//                        p.setSubjectname(projectTeam.getSubjectname());
//                        p.setName(projectTeam.getName());
//                        projectTeamMapper.insertProjectTerm(p);
//                    }
//
//                }
//
//            }
//        }

    }

    @Autowired
    private ProjectTeamServiceImpl projectTeamServiceImpl;

    /**
     * @Description : 转换返回到前端的格式
     * @param ： persons
     * @author : Liun
     * @date : 2020/6/8
     */
    public String  formatPerson(List<String> persons){
        List<String> personNew=new ArrayList<>();
        String personNow;
        for(String person:persons){
            personNow=person.replace("[","").replace("]","");
            personNew.add(personNow);
        }
        JSONArray json = JSONArray.fromObject(personNew);
        String users=json.toString();
        String lastUsers= projectTeamServiceImpl.createUser(users);
        return lastUsers;
    }




    public String getString(Object object){
        return object==null?"":object.toString();
    }

    public String generationId(String tableName){
        String   uuid  = UUID.randomUUID().toString().replace("-","");

        String uuid1 = testMapper.selectTableById(uuid,tableName);
        if(uuid1 != null){
            generationId(tableName);
        }
        return uuid;
    }



    /**
     * @Description : 发送钉钉待办通知
     * @param ： receivers
     */
    public void sendMessage(String receivers,String url,String content,String titele){
        log.info("发起流程,{}",content);
        IMMessageFacade imMessageFacade =this.dubboConfigService.getImMessageFacade();
        MessageModel messageModel = new MessageModel();
        messageModel.setReceivers(receivers);
        messageModel.setUrl(url);
        messageModel.setChannel(IMMessageChannelType.DINGTALK);
        messageModel.setMessageType(IMMessageType.BUSINESS_REMIND);
        messageModel.setContent(content);
        messageModel.setTitle(titele);
        imMessageFacade.sendMessage(messageModel);
    }
}
